package com.edu.exam.enums.questionbank;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 试题难度调整类型枚举
 *
 * @author System
 * @version 1.0.0
 */
public enum DifficultyAdjustmentType implements BaseEnum {

    MANUAL("MANUAL", "手动调整"),
    AUTO("AUTO", "自动调整"),
    SYSTEM("SYSTEM", "系统调整"),
    ALGORITHM("ALGORITHM", "算法调整"),
    STATISTICAL("STATISTICAL", "统计分析调整"),
    FEEDBACK("FEEDBACK", "反馈调整");

    private final String code;
    private final String description;

    DifficultyAdjustmentType(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public static DifficultyAdjustmentType fromCode(String code) {
        if (code == null || code.trim().isEmpty()) {
            throw new IllegalArgumentException("DifficultyAdjustmentType code cannot be null or empty");
        }
        for (DifficultyAdjustmentType type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown DifficultyAdjustmentType code: " + code);
    }

    public static DifficultyAdjustmentType fromDescription(String description) {
        if (description == null || description.trim().isEmpty()) {
            throw new IllegalArgumentException("DifficultyAdjustmentType description cannot be null or empty");
        }
        for (DifficultyAdjustmentType type : values()) {
            if (type.getDescription().equals(description)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown DifficultyAdjustmentType description: " + description);
    }

    @Override
    public String toString() {
        return this.code + "(" + this.description + ")";
    }
}